<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>title</title>
    <link rel="stylesheet" type="text/css" href="../../css/aui.css" />
    <link rel="stylesheet" type="text/css" href="../../css/api.css" />
    <style>
        html {
            font-size: 20px !important;
        }

        .aui-title {
            color: #303030 !important;
            font-size: 0.8rem !important;
        }

        .aui-pull-right {
            color: #2780e8 !important;
            font-size: 0.7rem !important;
        }
    </style>
</head>

<body>
    <header class="aui-bar aui-bar-nav aui-bar-light hd" id="app" v-cloak>
        <a id="back" class="aui-pull-left aui-btn" onclick="api.closeWin()">
            <img src="../../image/icon_back.png" style="width: 0.45rem;height: 0.8rem;margin-left: 0.7rem;" alt="">
        </a>
        <div class="aui-title">
            添加药材
        </div>

        <a class="aui-pull-right aui-btn" @click="save()">
            保存
        </a>
    </header>


</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/hb.js"></script>
<script type="text/javascript" src="../../script/vue.js"></script>
<script type="text/javascript">
    apiready = function () {
        init();
        initVue();
        openFrame('drugs', api.pageParam);
    }

    function init() {
        //开启沉静式
        var header = $api.dom('.hd');
        if (header) {
            $api.fixStatusBar(header);
        }
    } //endinit
    //打开一个frame
    function openFrame(name, ppm) {
        var hh = $api.offset($api.dom('.hd')) ? $api.offset($api.dom('.hd')).h : 0;
        var fh = $api.offset($api.dom('footer')) ? $api.offset($api.dom('footer')).h : 0;
        api.openFrame({
            name: name,
            url: name + '.html',
            pageParam: ppm,
            rect: {
                x: 0,
                y: hh,
                w: api.winWidth,
                h: api.winHeight - hh - fh
            }
        });
    }

    function initVue() {
        var app = new Vue({
            el: "#app",
            data: {
                allDrugs: [],
                allDrugsNum: 0,
                drugMoney: 0.000
            },
            created:function(){
                if(api.pageParam.allDrugs){
                  this.allDrugs = api.pageParam.allDrugs;
                }
                $this = this;
                api.addEventListener({
                    name: 'allDrugs'
                }, function (ret, err) {
                    $this.allDrugs = ret.value.allDrugs;
                    $this.drugMoney = ret.value.drugMoney;
                });
            },
            methods:{
                save: function(){
                    api.sendEvent({
                        name: 'checkDrugsMask',
                        extra: {}
                    });
                }
            }//endmethods
        }); //endinit
    } //endfunction
</script>

</html>
